home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-02 | 2.3 KB | 69 lines | [TEXT/CCL2] |
- ;;; backup-files.lisp
- ;;;
- ;;; Paul McCartney, Spring 1992
- ;;;
- ;;; Copyright © 1992 Paul McCartney. All Rights Reserved.
- ;;;
- ;;; Washington University Medical Informatics Training Program
- ;;;
- ;;; DESCRIPTION:
- ;;;
- ;;; Given the name of a source directory and the name of a destination
- ;;; directory, if the source directory and the containing directory
- ;;; of the destination directory exist, then create a copy of all
- ;;; source directory folders (recursively) and copy all files matching
- ;;; a pattern that are newer than the corresponding files in the destination
- ;;; directory (if they exist)
- ;;;
- ;;; USE:
- ;;;
- ;;; backup-files
- ;;;
- ;;; E.G:
- ;;; (backup-files "IDDI;" "HD105:Paul:IDDI-back:" "*.lisp")
- ;;;
- ;;; HISTORY:
- ;;;
- ;;; 4/20/92 Created. - PM
- ;;;
-
- (in-package :ccl)
-
- (eval-when (:compile-toplevel :load-toplevel :execute)
- (export '(backup-files) :ccl))
-
-
- (defun backup-files (source destination &optional (pattern "*"))
- (when (and (probe-file source) (probe-file destination))
- (format t "~%~%Backing up ~s~%" source)
- (with-cursor *watch-cursor*
- (backup-files-1 source destination pattern))) )
-
-
- (defun backup-files-1 (source destination pattern)
- (let* ((dir-pattern (concatenate 'simple-string source "*"))
- (dirs (directory dir-pattern :directories t :files nil))
- (file-pattern (concatenate 'simple-string source pattern))
- (files (directory file-pattern :directories nil :files t)))
- (if (null (probe-file destination))
- (create-file destination :if-exists nil))
- (dolist (dir dirs)
- (backup-files-1 (namestring dir)
- (add-last-folder-to-path dir destination)
- pattern))
- (dolist (file files)
- (let ((new-file (merge-pathnames destination file)))
- (when (or (null (probe-file new-file))
- (> (file-write-date file) (file-write-date new-file)))
- (format t "Writing file: ~s~%" new-file)
- (copy-file file new-file :if-exists :overwrite)) )) ))
-
-
- (defun add-last-folder-to-path (src-path dest-path)
- (let ((last-folder (first (last (pathname-directory
- (mac-directory-namestring src-path)))))
- (mac-dest (mac-namestring dest-path)))
- (concatenate 'simple-string mac-dest (string last-folder) ":") ))
-
-
- (provide :backup-files)